import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
import matplotlib.pyplot as plt
from sklearn.tree import DecisionTreeRegressor

data = pd.read_csv('./datasets/melb_data.csv')
d2 = data.head()
num_col = [col for col in data.columns if data[col].dtype in ['int','float']]
data = data[num_col]
# data.dropna(axis = 1,inplace=True)
miss_col = [col for col in data.columns if data[col].isnull().any()>0]
print(data[miss_col].isnull().sum())
print(data.shape)


# y = data.Price
# X_col = ['Rooms', 'Bathroom', 'Landsize', 
#          'BuildingArea', 'YearBuilt', 'Lattitude', 'Longtitude']
# X = data[X_col]
# X_train,X_vaild,y_train,y_vaild = train_test_split(X,y,train_size=0.8,random_state=0)
# col_missing_val = [col for col in X_col if data[col].isnull().any()]
# X_train.dropna(axis=1,inplace=True)
# X_vaild.dropna(axis=1,inplace=True)

# #建立模型
# model = RandomForestRegressor(random_state=1)
# model.fit(X_train, y_train)
# pre_y = model.predict(X_vaild)
# plt.figure(figsize=(20,8),dpi=80)
# plt.plot(pre_y,y_vaild,'.')
# plt.show()